package com.dylon.baseStudy;

/**
 * Volatile
 */
public class VolatileTest {

    private static int num1 = 1;
    private volatile static int num2 = 1;

    public static void main(String[] args) {

        new Thread(() -> {
            for (int i = 0; i < 10; i++) {
                num1++;
                num2++;
            }
            System.out.println("ta-num1:"+num1);
            System.out.println("ta-num2:"+num2);
        }).start();
        new Thread(() -> {
            for (int i = 0; i < 10; i++) {
                num1++;
                num2++;
            }
            System.out.println("tb-num1:"+num1);
            System.out.println("tb-num2:"+num2);
        }).start();
    }

}
